<template>
<div class="icons">
  <swiper :options="swiperOption">
    <swiper-slide v-for="(page, index) of pages" :key="index">
      <div class="icon" v-for="item of page" :key='item.id'>
      <div class="icons-img">
        <img :src="item.imgUrl" alt="">
      </div>
      <p>{{item.info}}</p>
    </div>
    </swiper-slide>
  </swiper>
</div>
</template>
<script>
export default {
  name: 'HomeIcons',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        autoplay: false
      }
    }
  },
  computed: {
    pages () {
      const pages = []
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>
<style lang='stylus' scoped>
@import '~styles/varibles.styl'
@import '~styles/minins.styl'
  // .icons
  //   height: 0
  //   padding-bottom: 42.67%
  //   overflow: hidden
  .icons >>> .swiper-container
    height: 0
    padding-bottom: 42.67%
    // overflow: hidden  swiper自带overflow，所以不需要设置
  .icons
    margin-top: .7rem
    margin-bottom: .7rem
  .icon
    position: relative
    width: 25%
    height: 0
    float: left
    padding-bottom: 22%
    overflow: hidden
  .icons-img
    position: absolute
    top: 0
    left: 0
    right: 0
    bottom: 2rem
    padding: .1rem
  .icons-img img
    width: 70%
    display: block
    margin: 0 auto
  .icon p
    position: absolute
    text-align: center
    bottom: .6rem
    width: 100%
    color: $darkTextColor
    ellipsis()
</style>
